//
// Created by wujehy on 2020/11/18.
//

#ifndef MOSQUITTO_AUTH_PLUGIN_ACLDB_H
#define MOSQUITTO_AUTH_PLUGIN_ACLDB_H
#include <string>

namespace SQLite
{
    class Database;
}
class AclDB
{
    const std::string m_table_name = "AclDB";
    SQLite::Database *m_database = nullptr;
public:

    struct AclDataType{
        std::string username ;
        std::string topic ;
        int         status ; /// < 权限状态 位操作
        int64_t     Createat;
        int64_t     ModifyAt;
    };
    AclDB(SQLite::Database *mDatabase);
    void init();

    int add(const std::string &username , const std::string &topic , int status );
    int update(const std::string &username , const std::string &topic , int status);
    int del(const std::string &username , const std::string &topic);
    int getTopicStatus(const std::string &username , const std::string &topic , int &status);
    int creatTable();
};

#endif //MOSQUITTO_AUTH_PLUGIN_ACLDB_H
